/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListeFilms.java
 *
 * Created on 18 janv. 2011, 17:45:28
 */
package org.cinema.view.user;

import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import org.cinema.dao.film.FilmsInfo;
import org.jdesktop.application.Action;

/**
 *
 * @author lynda
 */
public class FilmDetail extends javax.swing.JPanel
{
	private Runnable clickQuitter;

	/** Creates new form ListeFilms */
	public FilmDetail() throws InstantiationException, IllegalAccessException
	{
		initComponents();

	}

	public void setFilm (FilmsInfo fi)
	{
		titre.setText(fi.getTitre());
		resume.setText(fi.getResume());
		acteur.setText(fi.getActeur());
		duree.setText(fi.getDuree().toString());
		datesortie.setText(fi.getDateSortie().toString());

		try
		{
			image.setIcon(new ImageIcon(ImageIO.read(new File("./tools/images/" + fi.getImage())).getScaledInstance(image.getPreferredSize().width, image.getPreferredSize().height, 0)));
		}
		catch (IOException ex)
		{
			Logger.getLogger(FilmElement.class.getName()).log(Level.SEVERE, null, ex);
		}

		float pop = fi.getPopularite();
		if (pop < 0.2)
		{
			popularite.setText("Navet");
			popularite.setForeground(Color.LIGHT_GRAY);
		}
		else if (pop < 0.4)
		{
			popularite.setText("Moyen");
			popularite.setForeground(Color.WHITE);
		}
		else if (pop < 0.6)
		{
			popularite.setText("Pas si mal");
			popularite.setForeground(Color.CYAN);
		}
		else if (pop < 0.8)
		{
			popularite.setText("Bon Film");
			popularite.setForeground(Color.ORANGE);
		}
		else
		{
			popularite.setText("Block Buster");
			popularite.setForeground(Color.GREEN);
		}

	}

	public void setClick (Runnable r)
	{
		clickQuitter = r;
	}
	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        titre = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        retour = new javax.swing.JButton();
        image = new javax.swing.JLabel();
        duree = new javax.swing.JLabel();
        datesortie = new javax.swing.JLabel();
        acteur = new javax.swing.JLabel();
        popularite = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        resume = new javax.swing.JTextArea();

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setBackground(new java.awt.Color(102, 102, 102));
        setMinimumSize(new java.awt.Dimension(850, 356));

        jPanel1.setBackground(new java.awt.Color(153, 153, 153));
        jPanel1.setMaximumSize(new java.awt.Dimension(972, 332));

        titre.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
        titre.setForeground(new java.awt.Color(255, 255, 255));
        titre.setText("Titre");

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Date de Sortie :");

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Durée:");

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Résumé :");

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Acteurs :");

        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Popularité :");

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(org.cinema.view.user.CinemaApp.class).getContext().getActionMap(FilmDetail.class, this);
        retour.setAction(actionMap.get("quiter")); // NOI18N
        retour.setBackground(new java.awt.Color(122, 138, 153));
        retour.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        retour.setForeground(new java.awt.Color(255, 255, 255));
        retour.setText("Retour");

        image.setBackground(new java.awt.Color(0, 0, 0));
        image.setPreferredSize(new java.awt.Dimension(315, 291));

        duree.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        duree.setForeground(new java.awt.Color(255, 255, 255));
        duree.setText("duree...");

        datesortie.setFont(new java.awt.Font("Dialog", 0, 12));
        datesortie.setForeground(new java.awt.Color(255, 255, 255));
        datesortie.setText("datesortie...");

        acteur.setFont(new java.awt.Font("Dialog", 0, 12));
        acteur.setForeground(new java.awt.Color(255, 255, 255));
        acteur.setText("acteur...");

        popularite.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        popularite.setForeground(new java.awt.Color(255, 255, 255));
        popularite.setText("popularite...");

        resume.setBackground(new java.awt.Color(153, 153, 153));
        resume.setColumns(20);
        resume.setEditable(false);
        resume.setForeground(new java.awt.Color(255, 255, 255));
        resume.setLineWrap(true);
        resume.setRows(5);
        jScrollPane1.setViewportView(resume);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(image, javax.swing.GroupLayout.PREFERRED_SIZE, 273, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(60, 60, 60)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jLabel6))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel9))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(duree, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(datesortie, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(acteur, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(popularite, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(retour, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 526, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(titre, javax.swing.GroupLayout.PREFERRED_SIZE, 658, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(225, Short.MAX_VALUE)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(retour, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(106, 106, 106))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(duree, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(datesortie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(acteur, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(popularite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(image, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(titre)
                    .addContainerGap(303, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

	@Action
	public void quiter()
	{
		clickQuitter.run ();
	}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel acteur;
    private javax.swing.JLabel datesortie;
    private javax.swing.JLabel duree;
    private javax.swing.JLabel image;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel popularite;
    private javax.swing.JTextArea resume;
    private javax.swing.JButton retour;
    private javax.swing.JLabel titre;
    // End of variables declaration//GEN-END:variables
}



